package com.dq.domain.service.centre;

import com.dq.domain.base.BaseEntity;
import com.dq.domain.org.Org;
import com.dq.domain.service.ServiceProject;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

/**
 * @Author luchangtong
 * @Date 2020/4/3 10:26
 */
@Data
@Entity
@ApiModel("服务项目和门店关联表")
public class OrgServiceProject extends BaseEntity implements VO.ToVO{
    @ApiModelProperty("门店")
    @ManyToOne
    protected Org org;
    @ApiModelProperty("服务项目")
    @ManyToOne
    protected ServiceProject serviceProject;

    @Data
    @ApiModel(value = "服务项目视图")
    public static class Vo implements VO {
        public Long id;
        @ApiModelProperty("门店id")
        protected Long orgId;
        @ApiModelProperty("门店名")
        protected String orgName;
        @ApiModelProperty("服务项目id")
        public Long serviceProjectId;
        @ApiModelProperty("服务项目编号")
        protected String projectNo;

        @ApiModelProperty("服务项目名称")
        protected String projectName;

        @ApiModelProperty("服务项目价格")
        protected BigDecimal projectPrice;

        @ApiModelProperty("服务项目描述")
        protected String projectDescription;
        @ApiModelProperty("服务手工费")
        protected BigDecimal projectManualPrice;
        @ApiModelProperty("图片")
        protected String imgUrl;
        @ApiModelProperty("服务时间")
        protected Long serviceTime;

    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.orgId = this.getOrg() != null ? this.getOrg().getId() : null;
        vo.orgName = this.getOrg() != null ? this.getOrg().getSimpleName() : "";
        vo.serviceProjectId = this.getServiceProject() != null ? this.getServiceProject().getId() : null;
        vo.projectNo = this.getServiceProject() != null ? this.getServiceProject().getProjectNo() : "";
        vo.projectName = this.getServiceProject() != null ? this.getServiceProject().getProjectName() : "";
        vo.projectPrice = this.getServiceProject() != null ? this.getServiceProject().getProjectPrice() : null;
        vo.projectDescription = this.getServiceProject() != null ? this.getServiceProject().getProjectDescription() : "";
        vo.projectManualPrice = this.getServiceProject() != null ? this.getServiceProject().getProjectManualPrice() : null;
        vo.imgUrl = this.getServiceProject() != null ? this.getServiceProject().getImgUrl() : "";
        vo.serviceTime = this.getServiceProject() != null ? this.getServiceProject().getServiceTime() : null;
        return vo;
    }
}
